package com.xiaoshuidi.cloud.module.finance.enums.withdraw;

import com.xiaoshuidi.cloud.module.finance.enums.finance.PaymentSourceEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum TongLianRefundStatusEnum {

    // 未结算
    CREATE("01", "UNSETTLED","未结算"),
    // 正在结算中
    SUCCESS("05", "PROCESS","结算中"),
    // 结算失败
    FAILURE("08", "FAILURE","结算失败"),
    // 已结算
    CLOSE("09", "SUCCESS","已结算"),
    // 已合并
    ALREADY_MERGED("10", "SUCCESS","已结算"),
    // 冻结不结算
    FREEZE_NO_SETTLEMENT("11", "UNSETTLED","未结算"),
    // 其它方式结算
    OTHER_SETTLEMENT("12", "SUCCESS","已结算"),
    // 客户放弃结算
    ABANDONS_SETTLEMENT("13", "UNSETTLED","未结算"),
    // 已归集结算
    COLLECTED_SETTLED("14", "SUCCESS","已结算"),;

    private final String status;
    private final String name;
    private final String describe;

    public static boolean isSuccess(String status) {
        return Objects.equals(status, SUCCESS.getStatus());
    }

    public static String getName(String status) {
        for (TongLianRefundStatusEnum value : values()) {
            if (value.getStatus().equals(status)) {
                return value.getName();
            }
        }
        return "";
    }

    public static TongLianRefundStatusEnum getByCode(String code) {
        for(TongLianRefundStatusEnum e : TongLianRefundStatusEnum.values()){
            if(e.getName().equals(code)){
                return e;
            }
        }
        return null;
    }


}
